// pages/distribut/income/income.js
var app = getApp();
var request = app.request;
var setting = app.globalData.setting;
var common = require('../../../utils/common.js');
var util = require('../../../utils/util.js');
import LoadMore from '../../../utils/LoadMore.js'
var load = new LoadMore;
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		url: setting.url,
		week: [{
				id: 0,
				week: "周日",
				date: "21"
			},
			{
				id: 1,
				week: "周一",
				date: "22"
			},
			{
				id: 2,
				week: "周二",
				date: "23"
			},
			{
				id: 3,
				week: "周三",
				date: "24"
			},
			{
				id: 4,
				week: "周四",
				date: "25"
			},
			{
				id: 5,
				week: "周五",
				date: "26"
			},
			{
				id: 6,
				week: "周六",
				date: "27"
			}
		],
		time: app.getym(),
		currentdate: {
			hao: new Date().getDate(),
			zj: new Date().getDay(),
			datedq: app.globalData.parseTime(new Date(), '{y}-{m}-{d}'),
			nianyuer: app.globalData.parseTime(new Date(), '{y}年{m}月{d}日'),
		},
		currentlist: app.getDate(new Date()),
		zlist: ['周日', '周一', '周二', '周三', '周四', '周五', '周六', ],
		info: {},
		list: []
	},
	itemclick(e) {
		this.setData({
			time: app.globalData.parseTime(e.detail, '{y}年{m}月'),
			currentlist: app.getDate(e.detail),
			currentdate: {
				hao: new Date(e.detail).getDate(),
				zj: new Date(e.detail).getDay(),
				datedq: app.globalData.parseTime(e.detail, '{y}-{m}-{d}'),
				nianyuer: app.globalData.parseTime(e.detail, '{y}年{m}月{d}日')
			}
		})
		this.getData()
	},
	itemclick1(e) {
		this.setData({
			currentdate: e.detail
		})
		this.getData()
	},


	clickMenu(e) {
		// var that = this;
		// if (that.data.click) return false;
		// that.data.click = true;
		//在个人中心浏览其他入口页面前判断是否登录
		// if (!that.data.userInfo.user_id) {
		//   app.getUserInfo(function (userInfo) {
		//     that.setData({ userInfo: userInfo, click: false });
		//   }, true, false);
		//   return false;
		// }

		wx.navigateTo({
			url: e.currentTarget.dataset.url
		});
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		this.getData()
		this.getlist()
	},
	// 获取推荐分享商品
	getlist() {
		let that = this
		request.get('/api/shop/getRecommendGoods', {
			success: function(res) {
				if (res.data.status == 1) {
					that.setData({
						list: res.data.result
					});
				}
			}
		});
	},
	// 获取今日收入
	getData() {
		let that = this
		request.get('/api/shop/getCommissionByDay', {
			data: {
				day_time: that.data.currentdate.datedq
			},
			success: function(res) {
				if (res.data.status == 1) {
					that.setData({
						info: res.data.result
					});
				}
			}
		});
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},
	onShareAppMessage(e) {
		return {
			title: e.target.dataset.item.goods_name,
			path: '/pages/goods/goodsInfo/goodsInfo?goods_id=' + e.target.dataset.item.goods_id
		}
	},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

})